﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LIMS.Web
{
    public partial class Teacindex : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                AspNetPager1.RecordCount = BLL.NewsInfoManager.TotalCount();
                bindNewsInfo(1, 1);
            }
        }
  
        private void bindNewsInfo(Int32 pageSize, Int32 pageIndex)
        {
            rpNewsInfo.DataSource = BLL.NewsInfoManager.GetAllNews().Skip(pageSize * (pageIndex - 1)).Take(pageSize);
            rpNewsInfo.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            bindNewsInfo(AspNetPager1.PageSize, AspNetPager1.StartRecordIndex);
        }

        protected void rpNewsInfo_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {

        }



        protected String SubString(String strSource, Int32 Len)
        {
            return strSource.Length > Len ? strSource.Substring(0, Len) + "……" : strSource;
        }

        protected void ddlInfo_SelectedIndexChanged(object sender, EventArgs e)
        {
            rpNewsInfo.DataSource = BLL.NewsInfoManager.GetNewsByType(ddlInfo.SelectedValue);
            rpNewsInfo.DataBind();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            rpNewsInfo.DataSource = BLL.NewsInfoManager.SearchByTitle(txtCaption.Text.Trim());
            rpNewsInfo.DataBind();
        }

    }
}